extends Polygon2D

# Declare member variables here. Examples:
# var a = 2
# var b = "text"

var margin = 100
var lower_bound = 800
var Grid = null
var sea_level = 0
onready var vp_size = get_viewport().size

# Called when the node enters the scene tree for the first time.
func _ready():
	Grid = $"../GRID"
	sea_level = Grid.position.y + Grid.GROUND_LINE*Grid.BLOCKSIZE
	position = Vector2(0,0)

func _process(delta):
	var ar = PoolVector2Array()
	ar.append(Vector2(vp_size.x+margin,sea_level))
	ar.append(Vector2(vp_size.x+margin,lower_bound))
	ar.append(Vector2(-margin,lower_bound))
	ar.append(Vector2(-margin,sea_level))
	for i in range(len(Grid.displacement)):
		ar.append(Vector2(Grid.position.x,0)+Vector2(i*Grid.BLOCKSIZE,sea_level+Grid.displacement[i]))

	polygon = ar
